import java.util.concurrent.atomic.AtomicInteger;

public class Save implements Runnable {
//    private int balance = 0;
    AtomicInteger balance = new AtomicInteger(0);
    private static final int PER_SAVE = 1000;

    @Override
    public void run() {
        for (int i = 0; i < 3; ++i) {
            balance.addAndGet(PER_SAVE);
        }
    }

    public void show() {
        System.out.println("账户余额为: " + balance);
    }
}


class SaveTest {
    public static void main(String[] args) {
        Save save = new Save();
        Thread t1 = new Thread(save);
        Thread t2 = new Thread(save);
        t1.start();
        t2.start();

        try {
            t1.join();
            t2.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        save.show();
    }
}